package server;

/**
 * Responsible for handling the call back from clients
 * 
 * @author Simao Fernandes
 * 
 */
public interface ICallbackHandler extends java.rmi.Remote {
	/**
	 * Locks a cell for editing
	 * 
	 * @param abscissa
	 *            Cell position abscissa
	 * @param ordinate
	 *            Cell position ordinate
	 * @param uniqueId
	 * 			  unique identifier
	 * @return True if the lock was successfull otherwise returns false
	 * @throws RemoteException
	 *             A RemoteException instance
	 */
	boolean lockCell(int abscissa, int ordinate, java.util.UUID uniqueId)
			throws java.rmi.RemoteException;

	/**
	 * This remote method allows an object client to register for callback
	 * 
	 * @param callbackClientObject
	 *            Reference to the object of the client; to be used by the
	 *            server to make its callbacks
	 * @param uniqueId
	 * 			  Unique identifier           	
	 * @throws RemoteException
	 *             A RemoteException instance
	 */
	void registerForCallback(client.ICallbackHandler callbackClientObject, java.util.UUID uniqueId)
			throws java.rmi.RemoteException;

	/**
	 * This remote method allows an object client to cancel its registration for
	 * callback
	 * 
	 * @param callbackClientObject
	 *            Reference to the object of the client; to be used by the
	 *            server to make its callbacks
	 * @throws java.rmi.RemoteException
	 *             A RemoteException instance
	 */
	void unregisterForCallback(client.ICallbackHandler callbackClientObject)
			throws java.rmi.RemoteException;
	
	/**
	 * This remote method returns the result of a precedent operation
	 * (multiplication and division)
	 * @param expression Expression to evaluate
	 * @param uniqueId Unique identifier
	 * @return Precedent operation result
	 * @throws java.rmi.RemoteException RemoteException instance
	 */
	String getPrecedentOperationResult(String expression, java.util.UUID uniqueId)
			throws java.rmi.RemoteException;
	
	/**
	 * Updates the respective cell on other colaborators
	 * @param uniqueId uniquiId
	 * @param value New value
	 * @throws java.rmi.RemoteException RemoteException instance
	 */
	void updateColaboratorsCell(java.util.UUID uniqueId, String value)
			throws java.rmi.RemoteException;
}
